import request from '@/nx/request';
export default {
  // 微信账号登录
  wxAccountLogin: (data) => request({
    url: '/user/wx_login',
    method: 'POST',
    data,
    custom: {
      showSuccess: true,
      loadingMsg: '登录中',
    },
  }),
  // 非微信账号登录
  accountLogin: (data) => request({
    url: '/user/login',  // 不用 / 开头，就会加入配置的默认开头项
    method: 'POST',
    data,
    custom: {
      showSuccess: true,
      loadingMsg: '登录中',
    },
  }),
  userRegister: (data) => request({
    url: '/user',
    method: 'POST',
    data,
    custom: {
      showSuccess: true
    }
  }),

  // 获取用户信息
  profile: () => request({
    url: '/user',
    method: 'GET',
    custom: {
      showLoading: false,
      auth: true,
    },
  }),
  // 账号登出
  logout: (data) => request({
    url: '/user/api/user/logout',
    method: 'POST',
    data,
  }),
  // 属性token，header中需改为refreshToken
  refresh: () => request({
    url: '/user/refresh_token',
    method: 'POST',
    custom:{
      rToken: true,
    }
  }),
  // 测试jwt用
  // jwtTest: () => request({
  //   url: '/test',
  //   method: 'GET',
  // }),
  updateInfo: (data)=> request({
    url: '/user',
    method:'PUT',
    data,
  }),
  testUsername: (data) =>request({
    url:'/user/login',
    method:'GET',
    data,
    custom:{
      showError: false,
      // 显示请求时loading模态框 默认显示
      showLoading: false,
    }
  })
}